// MailNoter - A capture tool for emails

// Copyright (C) 2009 - MailNoter

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//

#include "stdafx.h"
#include "resource.h"
#include "InfoConfigDlg.h"

#include <string>


CInfoConfigDlg::CInfoConfigDlg(HWND hParent)
    : regAppendix(_T("Software\\MailNoter\\appendix"), DEFAULT_APPENDIX)
    , m_hParent(hParent)
{
}

CInfoConfigDlg::~CInfoConfigDlg(void)
{
}

LRESULT CInfoConfigDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);
    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            InitDialog(hwndDlg, IDI_MAILNOTER);
            // initialize the controls
            SetDlgItemText(*this, IDC_HTMLSTRING, std::wstring(regAppendix).c_str());
        }
        return TRUE;
    case WM_COMMAND:
        return DoCommand(LOWORD(wParam), HIWORD(wParam));
    default:
        return FALSE;
    }
    return FALSE;
}

LRESULT CInfoConfigDlg::DoCommand(int id, int /*msg*/)
{
    switch (id)
    {
    case IDOK:
        {
            TCHAR buf[65535] = {0};
            ::GetDlgItemText(*this, IDC_HTMLSTRING, buf, 65535);

            regAppendix = std::wstring(buf);
        }
        // fall through
    case IDCANCEL:
        EndDialog(*this, id);
        break;
    case IDC_DEFAULT:
        {
            SetDlgItemText(*this, IDC_HTMLSTRING, DEFAULT_APPENDIX);
        }
        break;
    }
    return 1;
}
